<!--
 * @Author: wjk
 * @Date: 2020-10-21 09:52:34
 * @LastEditors: wjk
 * @LastEditTime: 2021-01-13 11:09:29
 * @description: file content
-->

<template>
  <base-page-view class-name="page-container box-page">
    <view v-for="(boxList,index) in list" :key="index" class="list">
      <view class="title">
        <!-- <span class="icon"></span> -->
        <span>{{ boxList.title }}</span>
        <image src="/static/images/icon/icon_arror_right_grey.png" class="look_more_img" />
        <span class="look_more" @click="toMore(boxList)">查看更多</span>
      </view>
      <view class="list_box_all">
        <view class="list_box b_b">
          <view class="box b-r">
            <view>{{ boxList.selfBoxNum }}</view>
            <view class="text">自购箱数</view>
          </view>
          <view class="box">
            <view>{{ boxList.teamBoxNum }}</view>
            <view class="text">活动箱数</view>
          </view>
        </view>
        <view class="list_box">
          <view class="box b-r">
            <view v-if="boxList.personalMoney >= 0">{{ boxList.personalMoney| formatMoney }}</view>
            <view v-else class="totalPriceRed">{{ Math.abs(boxList.personalMoney) | formatMoney }}</view>
            <view class="text">预估自购折扣（元）</view>
          </view>
          <view class="box">
            <view>{{ boxList.teamMoney | formatMoney }}</view>
            <view class="text">预估活动折扣（元）</view>
          </view>
        </view>
      </view>
    </view>
    <view v-if="list.length<1" class="empty_view">
      <image src="/static/images/commission/commission-empty.png" class="empty_img" />
      <view class="tit">暂无任何内容</view>
    </view>
  </base-page-view>
</template>

<script>
import './index.scss'
export default {
  components: {
  },
  data() {
    return {
      list: [],
      monthValue: ''
    }
  },
  created() {

  },
  onLoad(option) {

  },
  onPullDownRefresh() {
    // this.pageNo = 1
    // this.listData = []
    // this.nomore = false
    this.list = []
    this.initData()
  },
  onShow() {
    const myDate = new Date()
    const year = myDate.getFullYear()
    let month = myDate.getMonth() + 1
    month = month > 9 ? month : '0' + month
    this.monthValue = year + '' + month
    this.initData()
  },
  methods: {
    async initData() {
      const res = await this.$api.commissionApi.getUserBoxing({ userId: this.$store.state.userInfo.uid, monthValue: this.monthValue })
      if (res.code === '000000') {
        this.list = res.data
        setTimeout(function() {
          uni.stopPullDownRefresh()
        }, 500)
      }
    },
    toMore(item) {
      if (item.type === 1) {
        this.$navigateTo('/pagesCommission/box/boxDetailsNew?ruleId=' + item.ruleId)
      } else {
        this.$navigateTo('/pagesCommission/box/boxDetails?ruleId=' + item.ruleId)
      }
    }
  }
}
</script>
